import Vue from 'vue'
// import Router from 'vue-router'
import Router from '../vue-router/index'
import Home from '../views/Home.vue'
import About from '../views/About.vue'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home
    },
    {
      path: '/about',
      name: 'About',
      component: About,
      children:[
        {
          path: 'a',
          component: {
            render: (h) => {
              return h('h1', 'About A')
            }
          }
        },
        {
          path: 'b',
          component: {
            render: (h) => {
              return h('h1', 'About B')
            }
          }
        }
      ]
    }
  ]
})

// 导航变化时，会一次执行者两个方法
router.beforeEach((from, to, next) => {
  setTimeout(() => {
    next()
  }, 1000);
})

router.beforeEach((from, to, next) => {
  setTimeout(() => {
    next()
  }, 1000);
})

export default router